﻿using Compass.Maui.Pages.Cargoes;
using Compass.Maui.Pages.FinishGoods;
using Compass.Maui.Services.Cargoes;
using Compass.Maui.Services.FinishGoods;
using Compass.Maui.ViewModels.Cargoes;
using Compass.Maui.ViewModels.FinishGoods;

namespace Compass.Maui;

//各种注册的扩展类
public static class Register
{
    /// <summary>
    /// 注册依赖注入服务
    /// </summary>
    public static MauiAppBuilder RegisterAppServices(this MauiAppBuilder builder)
    {
        builder.Services.AddScoped<IHttpRestClient, HttpRestClient>();
        builder.Services.AddScoped<INavigationService, NavigationService>();
        builder.Services.AddScoped<IPreferenceService, PreferencesService>();
        builder.Services.AddScoped<ILoginService, LoginService>();
        builder.Services.AddScoped<IMainPlanService, MainPlanService>();

        //成品库存
        builder.Services.AddScoped<IFinishGoodsCountService, FinishGoodsCountService>();
        builder.Services.AddScoped<IPackingListService, PackingListService>();
        builder.Services.AddScoped<IPalletService, PalletService>();


        //物料库存
        builder.Services.AddScoped<ICargoService, CargoService>();
        builder.Services.AddScoped<IInventoryService, InventoryService>();

        return builder;
    }
    /// <summary>
    /// 注册View和ViewModel
    /// </summary>
    public static MauiAppBuilder RegisterViewModels(this MauiAppBuilder builder)
    {
        //注册依赖注入,同时注册view和viewmodel，由.UseMauiCommunityToolkit()提供
        builder.Services.AddScoped<AppShell, AppShellViewModel>();
        builder.Services.AddScoped<LoginPage, LoginPageViewModel>();
        builder.Services.AddScoped<MainPage, MainPageViewModel>();
        builder.Services.AddScoped<MainPlansPage, MainPlansPageViewModel>();


        //成品库存
        builder.Services.AddScoped<FinishGoodsCountsPage, FinishGoodsCountsPageViewModel>();
        builder.Services.AddScoped<PackingListsPage, PackingListsPageViewModel>();

        builder.Services.AddScoped<PackingInfoPage,PackingInfoPageViewModel>();
        builder.Services.AddScoped<WarehousingPage,WarehousingPageViewModel>();
        builder.Services.AddScoped<WarehousingPalletPage,WarehousingPalletPageViewModel>();
        builder.Services.AddScoped<ShippingPage, ShippingPageViewModel>();
        builder.Services.AddScoped<ShippingPalletPage, ShippingPalletPageViewModel>();
        builder.Services.AddScoped<WeighingPage, WeighingPageViewModel>();
        builder.Services.AddScoped<WeighingPalletPage, WeighingPalletPageViewModel>();


        //物料库存
        builder.Services.AddScoped<CargoesInquiryPage, CargoesInquiryPageViewModel>();
        builder.Services.AddScoped<InventoriesPage, InventoriesPageViewModel>();



        return builder;
    }

    /// <summary>
    /// 注册未在Shell层次结构中显示注册路由的页面(全局导航)
    /// </summary>
    public static void RegisterRouting()
    {
        //成品库存
        Routing.RegisterRoute(nameof(FinishGoodsCountsPage), typeof(FinishGoodsCountsPage));
        Routing.RegisterRoute(nameof(PackingListsPage),typeof(PackingListsPage));
        Routing.RegisterRoute(nameof(PackingInfoPage),typeof(PackingInfoPage));
        Routing.RegisterRoute(nameof(WarehousingPage),typeof(WarehousingPage));
        Routing.RegisterRoute(nameof(WarehousingPalletPage),typeof(WarehousingPalletPage));
        Routing.RegisterRoute(nameof(ShippingPage), typeof(ShippingPage));
        Routing.RegisterRoute(nameof(ShippingPalletPage), typeof(ShippingPalletPage));
        Routing.RegisterRoute(nameof(WeighingPage), typeof(WeighingPage));
        Routing.RegisterRoute(nameof(WeighingPalletPage), typeof(WeighingPalletPage));


        //物料库存
        Routing.RegisterRoute(nameof(CargoesInquiryPage),typeof(CargoesInquiryPage));
        Routing.RegisterRoute(nameof(InventoriesPage),typeof(InventoriesPage));


    }
}